package com._119yn.host.gst200.model;

import lombok.Data;
import org.springframework.http.HttpStatus;

@Data
public class Rv {

    private Integer code;
    private String msg;
    private Long timestamp;
    public static final String TIP_SUCCESS = "success";
    public static final String TIP_ERROR = "error";

    public static Rv success() {
        return success(TIP_SUCCESS);
    }

    public static Rv success(String msg) {
        Rv rv = new Rv();
        rv.setCode(HttpStatus.OK.value());
        rv.setMsg(msg);
        rv.setTimestamp(System.currentTimeMillis());
        return rv;
    }

    public static Rv error() {
        return error(TIP_ERROR);
    }

    public static Rv error(String msg) {
        Rv rv = new Rv();
        rv.setCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
        rv.setMsg(msg);
        rv.setTimestamp(System.currentTimeMillis());
        return rv;
    }

}
